<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生产计划详情页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
    <script src="../../../res/js/util.js"></script>
    <script type="text/javascript" src="../../../res/js/jquery-3.4.1.min.js"></script>

</head>

<body>

<input type="hidden" id="planId" name="planId">

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">

        <!--<button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs" lay-event="addDrug">药品操作</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/html" id="barDemo1">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script type="text/html" id="img">
    <img src="{{d.images}}" width="50" height="50" onclick="showBig(this)"/>
</script>


<script type="text/html" id="input">
    <div class="layui-inline">
        <input class="layui-input" maxlength="8" style="border:none;padding-bottom:8px;" name="num" id="{{d.num}}" autocomplete="off" placeholder="输入药品数量" value="{{d.num}}" onblur="clearNoNum(this);">
    </div>

</script>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script src="../../../res/layui/layui.js" charset="utf-8"></script>
<script>


    var el = null;
    var openIndex = null;
    var table = null;
    var array = new Array();
    layui.use(['table', 'layer'], function () {
        table = layui.table;

        getData();




    });


    /**
     * 关闭层
     */
    function closeOpen(msg) {
        layer.close(openIndex);
        layer.msg(msg, {time: 1000}, function () {
            table.reload("test");//刷新表格
        })
    }

    /**
     * 获取已有的生成计划详情
     */
    function getData(){
        let id = getQueryString("id");
        $.ajax({
            url:"../../../hqPdetail/selectOne",
            type:"get",
            data:{planId:id},
            dataType: "json",
            async:false,
            success:function (obj) {
                $.each(obj,function (index,item) {
                    array.push(item);
                })
                refresh(array);
            }
        })

    }

    /**
     * 图片
     */
    function showBig(obj) {
        $("#imgDiv").fadeToggle(1000);
        $("#imgDiv_img").prop("src", obj.src)
    }

    function refresh(obj){
        table.render({
            elem: '#test'
            ,data: obj
            //, url: '../../../hqPdetail/selectOne?planId='+$("#planId").val()
            //, toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            /*, defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]*/
            , title: '计划明细表'
            , cols: [[
                {type: 'checkbox',fixed: 'left'}
                , {field: 'planName', title: '计划名称', width: 120}
                , {field: 'typeName', title: '药品类型', width: 120}
                , {field: 'drugName', title: '药品名称', width: 120}
                , {field: 'alias', title: '别名', width: 100}
                , {field: 'num', title: '数量', width: 150}
                , {field: 'price', title: '价格', width: 150}
                , {field: 'remark' ,title: '备注', width: 150}
                // , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 220}
            ]]
            , page: true

        });
    }

</script>
<div id="imgDiv" style="display:none;position:absolute;left:20%;top:10%">
    <img src="" id="imgDiv_img" width="100%" height="100%" onclick="showBig(this)">
</div>
</body>
</html>